package org.blade.personal.dao.base;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Query;

import org.blade.personal.dao.base.jpa.JpaDaoImpl;
import org.blade.personal.mode.BaseEntity;

/**
 * 建议使用jdbcTemplate来做查询， 其他操作交给hibernate 实现读写分离。
 * 
 * @author blade
 *
 * @param <T>
 * @param <ID>
 */
public class BaseDao2<T extends BaseEntity<ID>, ID extends Serializable> extends JpaDaoImpl<T, ID> {


	public int delete(String sql, String ids){
		return this.entityManager.createNativeQuery(sql)
				.setParameter(1, ids)
				.executeUpdate();
	}
	
	public List<T> queryForList(String querySql, Object[] params){
		Query query = this.entityManager.createNativeQuery(querySql);
		for(int i = 0 ; i< params.length; i++){
			query.setParameter(i, params[i]);
		}
		return query.getResultList();
	}

}
